package com.huawei.appgallery.forum.operation.report.fragment;

import android.content.res.Configuration;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.forum.base.card.bean.ImageInfo;
import com.huawei.appgallery.forum.cards.widget.FoldTextView;
import com.huawei.appgallery.forum.operation.report.adapter.ReportTypeAdapter;
import com.huawei.appgallery.forum.operation.report.view.widget.NoScrollListView;
import com.huawei.appgallery.foundation.ui.framework.widget.LineImageView;
import com.huawei.hmf.annotation.FragmentDefine;
import com.huawei.secure.android.common.intent.SafeBundle;
import huawei.widget.HwTextView;
import java.util.List;
import o.azb;
import o.brc;
import o.bse;
import o.bsv;
import o.btu;
import o.bww.a;
import o.bww.c;
import o.bww.d;
import o.bww.e;
import o.bww.h;
import o.bxm;
import o.bxn;
import o.bxv;
import o.dof;
import o.doo;
import o.equ;
import o.eqx;
import o.evk;
import o.fho;

@FragmentDefine(alias = "reportFragment")
public class ReportFragment extends Fragment {
    private int ʹ;
    private NoScrollListView ʻˊ;
    private ReportTypeAdapter ʻˋ;
    private int ʻᐝ;
    private RelativeLayout ʼ;
    private int ʼˊ;
    private bxv ʼˋ;
    private String ʼᐝ;
    private TextView ʽ;
    private long ʽˊ;
    private String ʽˋ;
    private String ʽᐝ = "";
    private String ʾॱ = "";
    private List<ImageInfo> ˉॱ;
    private LineImageView ˊ;
    private String ˊʻ;
    private String ˊʼ;
    private LineImageView ˋ;
    private LineImageView ˎ;
    private LinearLayout ˏ;
    private LineImageView ॱ;
    private ImageView ॱॱ;
    private HwTextView ᐝ;
    private ProgressBar ﹳ;
    private FoldTextView ﾞ;
    private LinearLayout ﾟ;

    public void ˏ(@Nullable Bundle bundle) {
        super.ˏ(bundle);
        this.ʼˋ = (bxv) new SafeBundle(ˊॱ()).getSerializable("reportContentInfo");
        ʼᐝ();
    }

    @Nullable
    public View ˋ(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
        View inflate = layoutInflater.inflate(a.ˎ, viewGroup, false);
        ˋ(inflate);
        ˎ(inflate);
        ʽᐝ();
        return inflate;
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        ˈॱ();
        ʾॱ();
    }

    private void ʼᐝ() {
        if (this.ʼˋ != null) {
            this.ʽˋ = this.ʼˋ.ˎ();
            this.ʼᐝ = this.ʼˋ.ˋ();
            this.ʾॱ = this.ʼˋ.ˊ();
            this.ˊʻ = this.ʼˋ.ˏ();
            if (!dof.ॱ(this.ʾॱ)) {
                this.ʾॱ = this.ʾॱ.replace("[br]", "\n");
            }
            this.ʽᐝ = this.ʼˋ.ॱ();
            if (!dof.ॱ(this.ʽᐝ)) {
                this.ʽᐝ = this.ʽᐝ.replace("[br]", "\n");
            }
            this.ʻᐝ = this.ʼˋ.ʼ();
            this.ʽˊ = this.ʼˋ.ʻ();
            if (this.ʼˋ.ॱॱ() != null && !this.ʼˋ.ॱॱ().isEmpty()) {
                this.ˉॱ = this.ʼˋ.ॱॱ();
                ˈॱ();
            }
        } else if (ॱˋ() != null) {
            ॱˋ().finish();
        }
    }

    private void ʽᐝ() {
        if (!TextUtils.isEmpty(this.ʽˋ)) {
            equ.ˊ(this.ॱॱ, this.ʽˋ, "head_default_icon");
        }
        this.ʽ.setText(this.ʼᐝ);
        this.ᐝ.setText(h.ˋॱ);
        if (this.ʻᐝ == 0) {
            int dimensionPixelSize = ᐝॱ().getDimensionPixelSize(c.ॱ);
            int dimensionPixelSize2 = ᐝॱ().getDimensionPixelSize(c.ˏ);
            this.ʼ.setPadding(dimensionPixelSize, 0, dimensionPixelSize2, 0);
            this.ﾞ.setPadding(dimensionPixelSize, 0, dimensionPixelSize2, 0);
            this.ˊʼ = this.ʾॱ;
        } else {
            this.ˊʼ = this.ʽᐝ;
        }
        ʽˊ();
        if (!(this.ʻᐝ == 0 && TextUtils.isEmpty(this.ʾॱ)) && (this.ʻᐝ == 0 || !TextUtils.isEmpty(this.ʽᐝ))) {
            this.ﾞ.setVisibility(0);
        } else {
            this.ﾞ.setVisibility(8);
        }
        ʾॱ();
        if (this.ʻˋ == null) {
            this.ʻˋ = new ReportTypeAdapter(ॱˋ());
        }
        this.ʻˊ.setAdapter(this.ʻˋ);
    }

    private void ʽˊ() {
        if (this.ʻᐝ == 1) {
            this.ﾞ.setMovementMethod(LinkMovementMethod.getInstance());
            this.ﾞ.setContent(btu.ॱ(ॱˋ(), this.ˊʼ, btu.ˏ()), false, azb.ॱ(ॱˋ()));
            return;
        }
        this.ﾞ.setMaxLines(3);
        this.ﾞ.setEllipsize(TruncateAt.END);
        this.ﾞ.setText(this.ˊʼ);
    }

    private void ʾॱ() {
        if (this.ˉॱ == null || this.ˉॱ.size() <= 0) {
            this.ʼ.setVisibility(8);
            return;
        }
        this.ʼ.setVisibility(0);
        if (this.ˉॱ.size() < 3) {
            ˎ(this.ˋ, this.ʹ, 0);
            this.ˋ.setVisibility(0);
            eqx.ˏ(this.ˋ, ((ImageInfo) this.ˉॱ.get(0)).ˊ(), "image_default_icon");
            this.ˏ.setVisibility(8);
            return;
        }
        this.ˋ.setVisibility(8);
        if (this.ˉॱ.size() >= 3) {
            ˎ(this.ˊ, this.ʼˊ, 1);
            ˎ(this.ॱ, this.ʼˊ, 1);
            ˎ(this.ˎ, this.ʼˊ, 1);
            this.ˏ.setVisibility(0);
            eqx.ˏ(this.ˊ, ((ImageInfo) this.ˉॱ.get(0)).ˊ(), "image_default_icon");
            eqx.ˏ(this.ॱ, ((ImageInfo) this.ˉॱ.get(1)).ˊ(), "image_default_icon");
            eqx.ˏ(this.ˎ, ((ImageInfo) this.ˉॱ.get(2)).ˊ(), "image_default_icon");
            return;
        }
        this.ˏ.setVisibility(8);
    }

    private void ˋ(View view) {
        View view2 = (ViewGroup) view.findViewById(d.ॱᐝ);
        azb.ˏ(view2);
        ((HwTextView) view2.findViewById(d.ʽॱ)).setText(ॱ(h.ॱˊ));
        ((ImageView) view2.findViewById(d.ˈ)).setImageDrawable(ᐝॱ().getDrawable(e.ˊ));
        view2.findViewById(d.ͺ).setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ ReportFragment ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.ˉॱ();
            }
        });
        this.ﾟ = (LinearLayout) view2.findViewById(d.ʻॱ);
        ((ImageView) view2.findViewById(d.ᐝॱ)).setImageDrawable(ᐝॱ().getDrawable(e.ˎ));
        this.ﾟ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ ReportFragment ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.ˊʻ();
            }
        });
        this.ﹳ = (ProgressBar) view2.findViewById(d.ʾ);
    }

    private void ˎ(View view) {
        azb.ˏ(view, d.ᐝ);
        this.ʼ = (RelativeLayout) view.findViewById(d.ˎ);
        azb.ˎ(this.ʼ);
        this.ˏ = (LinearLayout) view.findViewById(d.ʼ);
        this.ˋ = (LineImageView) view.findViewById(d.ˏ);
        this.ˊ = (LineImageView) view.findViewById(d.ʽ);
        this.ॱ = (LineImageView) view.findViewById(d.ʻ);
        this.ˎ = (LineImageView) view.findViewById(d.ॱॱ);
        this.ॱॱ = (ImageView) view.findViewById(d.ˊॱ);
        this.ʽ = (TextView) view.findViewById(d.ॱˊ);
        this.ﾞ = (FoldTextView) view.findViewById(d.ॱ);
        azb.ˎ(this.ﾞ);
        this.ʻˊ = (NoScrollListView) view.findViewById(d.ॱˎ);
        azb.ˏ(this.ʻˊ);
        azb.ˏ(view, d.ʿ);
        this.ᐝ = (HwTextView) view.findViewById(d.ॱˋ);
    }

    private void ͺ(boolean z) {
        int i;
        int i2 = 8;
        boolean z2 = false;
        ProgressBar progressBar = this.ﹳ;
        if (z) {
            i = 0;
        } else {
            i = 8;
        }
        progressBar.setVisibility(i);
        LinearLayout linearLayout = this.ﾟ;
        if (!z) {
            i2 = 0;
        }
        linearLayout.setVisibility(i2);
        NoScrollListView noScrollListView = this.ʻˊ;
        if (!z) {
            z2 = true;
        }
        noScrollListView.setEnabled(z2);
    }

    private void ˊʻ() {
        Object checkedReport = this.ʻˋ.getCheckedReport();
        if (TextUtils.isEmpty(checkedReport)) {
            evk.ॱ(ॱ(h.ʽ), 0).ˋ();
        } else if (doo.ˊ(ॱˊ())) {
            ͺ(true);
            ((brc) fho.ˏ().ˋ("Base").ॱ(brc.class)).ˋ(new bxm.a(this.ʻᐝ, this.ʽˊ, checkedReport).ˋ(bsv.ॱ(this.ˊʻ)).ˋ(), new brc.e<bxm, bxn>(this) {
                final /* synthetic */ ReportFragment ॱ;

                {
                    this.ॱ = r1;
                }

                public /* synthetic */ void ˋ(Object obj, Object obj2) {
                    ॱ((bxm) obj, (bxn) obj2);
                }

                public /* synthetic */ void ˏ(Object obj, Object obj2) {
                    ˎ((bxm) obj, (bxn) obj2);
                }

                public void ˎ(bxm o_bxm, bxn o_bxn) {
                }

                public void ॱ(bxm o_bxm, bxn o_bxn) {
                    this.ॱ.ͺ(false);
                    if (o_bxn.getResponseCode() == 0 && o_bxn.getRtnCode_() == 0) {
                        evk.ˏ(this.ॱ.ॱ(h.ˏॱ));
                        this.ॱ.ˉॱ();
                        return;
                    }
                    evk.ˏ(this.ॱ.ॱ(bse.ˏ.ॱ(o_bxn.getRtnCode_()).ˏ()));
                }
            });
        } else {
            evk.ˏ(ॱˊ(), h.ʽॱ, 0).ˋ();
        }
    }

    private void ˎ(View view, int i, int i2) {
        if (i2 == 0) {
            LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
            layoutParams.height = i;
            view.setLayoutParams(layoutParams);
        } else if (i2 == 1) {
            LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) view.getLayoutParams();
            layoutParams2.height = i;
            view.setLayoutParams(layoutParams2);
        }
    }

    private void ˈॱ() {
        int ॱ = azb.ॱ(ॱˋ()) - (ᐝॱ().getDimensionPixelSize(c.ˎ) * 2);
        this.ʹ = (int) (((double) ॱ) / 1.7777777777777777d);
        this.ʼˊ = (int) ((((double) (ॱ - (ᐝॱ().getDimensionPixelSize(c.ˋ) * 2))) / 3.0d) / 1.3333333333333333d);
    }

    private void ˉॱ() {
        if (ॱˋ() != null && !ॱˋ().isFinishing()) {
            ॱˋ().finish();
        }
    }

    public void ॱ() {
        if (ॱˋ() != null && this.ˊʼ != null && this.ﾞ != null) {
            this.ﾞ.postDelayed(new Runnable(this) {
                final /* synthetic */ ReportFragment ˏ;

                {
                    this.ˏ = r1;
                }

                public void run() {
                    this.ˏ.ʽˊ();
                }
            }, 500);
        }
    }
}
